/*     */ package com.zimbra.cs.mailbox;
/*     */ 
/*     */ import com.google.common.base.Splitter;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import java.util.Iterator;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public final class MailboxVersion
/*     */ {
/*     */   private static final short CURRENT_MAJOR = 2;
/*     */   private static final short CURRENT_MINOR = 7;
/*     */   private final short majorVer;
/*     */   private final short minorVer;
/*     */   static final String MD_CONFIG_VERSION = "ver";
/*  35 */   static final MailboxVersion CURRENT = new MailboxVersion();
/*     */   
/*     */   public static MailboxVersion getCurrent() {
/*  38 */     return CURRENT;
/*     */   }
/*     */   
/*     */   MailboxVersion() {
/*  42 */     this.majorVer = 2;
/*  43 */     this.minorVer = 7;
/*     */   }
/*     */   
/*     */   public MailboxVersion(short major, short minor) {
/*  47 */     this.majorVer = major;
/*  48 */     this.minorVer = minor;
/*     */   }
/*     */   
/*     */   MailboxVersion(MailboxVersion other) {
/*  52 */     this.majorVer = other.majorVer;
/*  53 */     this.minorVer = other.minorVer;
/*     */   }
/*     */   
/*     */   public short getMajor() {
/*  57 */     return this.majorVer;
/*     */   }
/*     */   
/*     */   public short getMinor() {
/*  61 */     return this.minorVer;
/*     */   }
/*     */   
/*     */   static MailboxVersion fromMetadata(Metadata md) throws ServiceException
/*     */   {
/*  66 */     short major = 1;
/*  67 */     short minor = 0;
/*     */     
/*  69 */     if (md != null) {
/*  70 */       major = (short)(int)md.getLong("vmaj", 1L);
/*  71 */       minor = (short)(int)md.getLong("vmin", 0L);
/*     */     }
/*     */     
/*  74 */     return new MailboxVersion(major, minor);
/*     */   }
/*     */   
/*  77 */   private static final Splitter SPLITTER = Splitter.on('.').trimResults();
/*     */   
/*     */   public static MailboxVersion parse(String s) {
/*  80 */     if (s == null) {
/*  81 */       return null;
/*     */     }
/*     */     
/*  84 */     Iterator<String> components = SPLITTER.split(s).iterator();
/*     */     try {
/*  86 */       short major = 1;
/*  87 */       short minor = 0;
/*     */       
/*  89 */       if (components.hasNext()) {
/*  90 */         major = Short.parseShort((String)components.next());
/*     */       }
/*  92 */       if (components.hasNext()) {
/*  93 */         minor = Short.parseShort((String)components.next());
/*     */       }
/*     */       
/*  96 */       MailboxVersion version = new MailboxVersion(major, minor);
/*  97 */       return version.isLatest() ? CURRENT : version;
/*     */     } catch (NumberFormatException nfe) {}
/*  99 */     return new MailboxVersion((short)1, (short)0);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean atLeast(int major, int minor)
/*     */   {
/* 109 */     return (this.majorVer > major) || ((this.majorVer == major) && (this.minorVer >= minor));
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean atLeast(MailboxVersion b)
/*     */   {
/* 117 */     return atLeast(b.majorVer, b.minorVer);
/*     */   }
/*     */   
/*     */   public boolean isLatest() {
/* 121 */     return (this.majorVer == 2) && (this.minorVer == 7);
/*     */   }
/*     */   
/*     */   public boolean tooHigh()
/*     */   {
/* 126 */     return (this.majorVer > 2) || ((this.majorVer == 2) && (this.minorVer > 7));
/*     */   }
/*     */   
/*     */   public String toString()
/*     */   {
/* 131 */     return this.majorVer + "." + this.minorVer;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailbox/MailboxVersion.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */